
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Rémi PIOTAIX <remi.piotaix@gmail.com>
 */
public class Test {

    public static void main(String[] args) throws URISyntaxException {
        
        URL[] urls = new URL[0];
        final ClassLoader newcl = new URLClassLoader(urls, ClassLoader.getSystemClassLoader());

        final ClassLoader syscl = ClassLoader.getSystemClassLoader();

        ClassLoader maincl = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(newcl);

        if (maincl == syscl) {
            System.out.println("maincl = syscl");
        }

        Thread t = new Thread() {
            @Override
            public void run() {
                ClassLoader threadcl = Thread.currentThread().getContextClassLoader();
                if (threadcl == syscl) {
                    System.out.println("threadcl = syscl");
                } else if (threadcl == newcl) {
                    System.out.println("threadcl = newcl");
                }
            }
        };
        
        t.start();
    }
}
